

function btnAdd(){
    console.log('新增');
    
}
function btnEdit(){
    console.log('编辑');
    
}
function btnFilter(){
    console.log('过滤');
    
}
function btnDel(){
    console.log('删除');
    
}
function btnSave(){
    console.log('保存');
    
}
function btnCancel(){
    console.log('取消');
    
}



window.addEventListener('load',function(){
    console.log('页面加载完成');
    axios.get(`http://localhost:3000/blogs`).then((res)=>{
        let data = res.data
        console.log(data);
        let tobody = this.document.querySelector('tobody');
       let html = `
                <tr>
                    <td>1</td>
                    <td>1</td>
                    <td>1</td>
                    <td>
                    <input type="button" value="编辑" onclick="btnEdit()">
                    <input type="button" value="删除" onclick="btnDel()">
                    </td>
                </tr>
       `
        
        if(data.code===1000){
            let blogs = data.data
            blogs.forEach(item => {
                let tr = this.document.createElement('tr');
                tr.innerHTML = `
                <tr>
                    <td>${item.id}</td>
                    <td>${item.title}</td>
                    <td>${item.author}</td>
                    <td>
                    <input type="button" value="编辑" onclick="btnEdit(${item.id})">
                    <input type="button" value="删除" onclick="btnDel(${item.id})">
                    </td>
                </tr>
                `
                tobody.appendChild(tr)

            });
        }
        
        
    })
    
})